﻿using Microsoft.AspNetCore.Mvc;
using MVC_System.DTO.Equipment;
using MVC_System.DTO.ProductionPlanning;
using MVC_System.DTO.Workshop;
using Newtonsoft.Json;
using WMS_MAV;

namespace MVC_System.Controllers
{
    /// <summary>
    /// 生产计划
    /// </summary>
    public class ProductionPlanningController : Controller
    {
        /// <summary>
        /// 服务
        /// </summary>
        private readonly IConfiguration _configuration;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="configuration">服务</param>
        public ProductionPlanningController(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        public IActionResult ProductionPlanningList()
        {
            return View();
        }
        /// <summary>
        ///生产显示
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> ProductionPlanningsShow(ProductionPlanningDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "Workshop/api/ProductionPlannings/Get?pageIndex=" + dto.pageIndex + "&pageSize=" + dto.pageSize + "&theProductionPlanNumber=" + dto.theProductionPlanNumber + "&productionStatus=" + dto.productionStatus + "&DeliveryDate=" + dto.DeliveryDate;
            var respomse = await client.GetAsync(url);
            return Json(respomse);
        }
        /// <summary>
        /// 生产删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> ProductionPlanningsDelete(ProductionPlanningDeleteDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "Workshop/api/ProductionPlannings/Deletes";
            var respomse = await client.PostAsync(url, dto.Data);
            return Json(respomse);
        }
        /// <summary>
        /// 生产反填
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> ProductionPlanningsFinds(ProductionPlanningModelDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "Workshop/api/ProductionPlannings/GetById?productionId=" + dto.productionId;
            var respomse = await client.GetAsync(url);
            return Json(respomse);
        }
        /// <summary>
        /// 生产修改 
        /// </summary>
        /// <param name="obj1"></param>
        /// <param name="token"></param>
        /// <returns></returns>1
        public async Task<ActionResult> ProductionPlanningsUpdate(ProductionPlanningUpdateDTO obj1, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "Workshop/api/ProductionPlannings/Update";
            string list = JsonConvert.SerializeObject(obj1);
            var response = await client.PostAsync(url, list);
            return Json(response);
        }

        /// <summary>
        ///生产查看
        /// </summary>
        /// <returns></returns>
        public IActionResult ProductionPlanningsFind()
        {
            return View();
        }
    }
}
